package com.springboot.springbootlogindemo.controller;

import com.springboot.springbootlogindemo.domain.Song;
import com.springboot.springbootlogindemo.service.CommentsService;
import com.springboot.springbootlogindemo.service.SongService;
import com.springboot.springbootlogindemo.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/song")
public class SongController {
    @Autowired
    private SongService songService;


    @Resource
    private CommentsService commentsService;





    /**
     * 创建歌曲，包括歌曲id，歌曲名，歌曲图片，歌手id，歌曲文件的地址，歌词，收藏数量，评论数量等
     * @param song
     * @return
     */
    @PostMapping("/addSong")
    public Result addSong(@RequestBody Song song) {
        return songService.addSong(song);
    }


    /**
     * 更新歌曲信息
     * @param song
     * @return
     */
    @PostMapping("/updateSong")
    public Result updateSong(@RequestBody Song song){
        return songService.updateSong(song);
    }

    /**
     * 获取所有歌曲信息
     * @return
     */
    @GetMapping("/getAll")
    public Result getAllSong(){
        return songService.getAllSongs();
    }

    /**
     * 根据歌曲名查找歌曲
     * @param name
     * @return
     */
    @GetMapping("/getSongsByName")
    public Result getSongsByName(@RequestParam String name){
        return songService.findSongsByName(name);
    }

    /**
     * 根据歌手查找歌曲
     * @param singerName
     * @return
     */
    @GetMapping("/getSongsBySingerId")
    public Result getSongsBySinger(@RequestParam String singerName){
        return songService.findSongsBySinger(singerName);
    }

    /**
     * 精准查找歌曲(根据歌曲名和歌手名)
     * @param songName
     * @param singerName
     * @return
     */
    @GetMapping("/getSong")
    public Result getSong(@RequestParam String songName,@RequestParam String singerName){
        return songService.fingSong(songName,singerName);
    }

    /**
     *获取歌曲评论
     * @param songId
     * @return
     */
    @GetMapping("/showComments")
    public Result showSongComments(@RequestParam Long songId){
        return commentsService.showSongComments(songId);
    }
}



            //修改歌曲信息，包括实现 收藏数量和评论数量的增加

